package com.letian.record.service.impl;

import java.util.List;
import com.letian.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.letian.record.mapper.RecordNoteMapper;
import com.letian.record.domain.RecordNote;
import com.letian.record.service.IRecordNoteService;

/**
 * 记录日记Service业务层处理
 * 
 * @author bmz
 * @date 2023-09-28
 */
@Service
public class RecordNoteServiceImpl implements IRecordNoteService 
{
    @Autowired
    private RecordNoteMapper recordNoteMapper;

    /**
     * 查询记录日记
     * 
     * @param noteId 记录日记主键
     * @return 记录日记
     */
    @Override
    public RecordNote selectRecordNoteByNoteId(Long noteId)
    {
        return recordNoteMapper.selectRecordNoteByNoteId(noteId);
    }

    /**
     * 查询记录日记列表
     * 
     * @param recordNote 记录日记
     * @return 记录日记
     */
    @Override
    public List<RecordNote> selectRecordNoteList(RecordNote recordNote)
    {
        return recordNoteMapper.selectRecordNoteList(recordNote);
    }

    /**
     * 新增记录日记
     * 
     * @param recordNote 记录日记
     * @return 结果
     */
    @Override
    public int insertRecordNote(RecordNote recordNote)
    {
        recordNote.setCreateTime(DateUtils.getNowDate());
        return recordNoteMapper.insertRecordNote(recordNote);
    }

    /**
     * 修改记录日记
     * 
     * @param recordNote 记录日记
     * @return 结果
     */
    @Override
    public int updateRecordNote(RecordNote recordNote)
    {
        recordNote.setUpdateTime(DateUtils.getNowDate());
        Long count = recordNote.getUpdateCount() == null ? 1 : recordNote.getUpdateCount() + 1;
        recordNote.setUpdateCount(count);
        return recordNoteMapper.updateRecordNote(recordNote);
    }

    /**
     * 批量删除记录日记
     * 
     * @param noteIds 需要删除的记录日记主键
     * @return 结果
     */
    @Override
    public int deleteRecordNoteByNoteIds(Long[] noteIds)
    {
        return recordNoteMapper.deleteRecordNoteByNoteIds(noteIds);
    }

    /**
     * 删除记录日记信息
     * 
     * @param noteId 记录日记主键
     * @return 结果
     */
    @Override
    public int deleteRecordNoteByNoteId(Long noteId)
    {
        return recordNoteMapper.deleteRecordNoteByNoteId(noteId);
    }
}
